//
//  JPDiseaseListModel.m
//  JPKY
//
//  Created by 周述坚 on 16/11/15.
//  Copyright © 2016年 Vitas. All rights reserved.
//

#import "JPDiseaseListModel.h"
#import "InterfaceTool.h"
#import <YYModel.h>

@implementation JPDiseaseListModel

+ (void)loadDataWithURLStr:(NSInteger)tag success:(void(^)(NSArray *newsList))successBlock failed:(void(^)(NSError *error))failedBlock {
    
    InterfaceTool *tool = [InterfaceTool sharedInterfaceTool];
  
    [tool getSubsectionWithDisease:tag Page:1 success:^(id  response) {
        
        NSDictionary *result = response;
        // 由于responseObject这个字典的key是变化的,跟tid是匹配的,所以需要动态获取responseObject的key
        // 动态获取字典的第一个KEY
        NSString *key = @"data";
        // 通过动态获取key,取字典数组
        NSArray *dictArr = result[key];
        // 使用YYModel把字典数组转模型数组
        NSArray *newsList = [NSArray yy_modelArrayWithClass:[JPDiseaseListModel class] json:dictArr];
        
        // 把获取的新闻数据的模型数组,回调到NewsVC
        if (successBlock != nil) {
            successBlock(newsList);
        }
        
    } failure:^(NSError *error) {
        NSLog(@"%@", error);
    }];
}

+ (void)loadDataWithDataSuccess:(void(^)(NSArray *newsList))successBlock failed:(void(^)(NSError *error))failedBlock {
    
    InterfaceTool *tool = [InterfaceTool sharedInterfaceTool];
    
    [tool getSelectComplicationSuccess:^(id response) {
        NSDictionary *result = response;
        // 由于responseObject这个字典的key是变化的,跟tid是匹配的,所以需要动态获取responseObject的key
        // 动态获取字典的第一个KEY
        NSString *key = @"data";
        // 通过动态获取key,取字典数组
        NSArray *dictArr = result[key];
        // 使用YYModel把字典数组转模型数组
        NSArray *newsList = [NSArray yy_modelArrayWithClass:[JPDiseaseListModel class] json:dictArr];
        
        // 把获取的新闻数据的模型数组,回调到NewsVC
        if (successBlock != nil) {
            successBlock(newsList);
        }
    } failure:^(NSError *error) {
         NSLog(@"%@", error);
    }];
}

@end
